from django.shortcuts import render
from django.http.response import HttpResponse

def index(request):
    """html视图"""
    data = {"name":"用户", "pwd":"密码"}
    # return render(request, template_name="index.html")
    return render(request, "index.html", data)


def index2(request):
    """模板引擎提供标签用于判断输出"""
    name = "root"
    return render(request, "index2.html", locals())


def index3(request):
    """使用for语句"""
    book_list = [
        {"id":1,"title":"红楼梦","price":39.91},
        {"id":2,"title":"西游记","price":49.03},
        {"id":3,"title":"水浒传","price":59.09},
        {"id":4,"title":"三国演义","price":79.09},
        {"id":5,"title":"海底两万里","price":69.73},
        {"id":6,"title":"鲁滨逊漂流记","price":89.05},
        {"id":7,"title":"简爱","price":99.90},
    ]
    return render(request, "index3.html", locals())


def index4(request):
    """过滤器"""
    title = "人生格言"
    content = "失败是成功他妈！"
    return render(request, "index4.html", locals())